import React, { Component } from 'react'
import EC  from "echarts-for-react";
import Axios from 'axios';

export default class Work extends Component {
    state={
        options:{}
    }
    render() {
        return (
            <div>
                <EC option={this.state.options} style={{width:400,height:200}}/>
            </div>
        )
    }
    componentDidMount(){
        Axios.get('/data/work').then(res=>{
            const {data} = res.data
            let options = {
                title: {
                    text: '促销活动类型活动个数统计'
                },
            xAxis: {
                type: 'category',
                data: data.map(item=>item.type)
            },
            yAxis: {
                type: 'value'
            },
            series: [{
                data: data.map(item=>item.num),
                type: 'bar',
                showBackground: true,
                backgroundStyle: {
                    color: 'rgba(220, 220, 220, 0.8)'
                }
            }]}
           this.setState({options:options})
        })
    }
}
